#include<stdio.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>

int main()
{
    umask(0000);
    //system call
    //chdir("..");
    //打开文件
    int fdirectory = open("log.txt", O_WRONLY | O_CREAT | O_TRUNC, 0666);
    if(fdirectory < 0)
    {
        perror("open");
    }

    //操作文件：
    const char* buf = "hello Linux file!";
    write(fdirectory, buf, strlen(buf));
    buf = "aaaa\n";
    write(fdirectory, buf, strlen(buf));
    
    //关闭文件：
    close(fdirectory);
    return 0;
}
